/**
* @author AlbertDarren
* @contact 2563491540@qq.com
*/
#include <iostream>
#include <algorithm>
#include <list>
#include <set>
#include <cstdlib>
#include <ctime>
using namespace std;
void show(auto &container)
{
    for(auto element:container)
    {
        cout << element << " ";
    }
    cout << endl;
}
int main_33()
{
    srand((unsigned int)time(nullptr));
    list<int> int_list;
    multiset<int> int_multiset;
    int random_int;
    for (int i=0; i<20 ; ++i )
    {
        random_int=rand()%20;
        int_list.push_back(random_int);
        int_multiset.insert(random_int);
    }
    show(int_list);
    int_list.sort();
    show(int_list);
    random_int=rand()%20;
    auto iter=lower_bound(int_list.begin(),int_list.end(),random_int);
    if (iter!=int_list.end())
    {
        cout << "The first element that is not less than "<<random_int<<" is at "<<distance(int_list.begin(),iter) << endl;
    }
    else
    {
        cout << "Every element is less than "<<random_int << endl;
    }
    iter=upper_bound(int_list.begin(),int_list.end(),random_int);
    if (iter!=int_list.end())
    {
        cout << "The first element that is greater than "<<random_int<<" is at "<<distance(int_list.begin(),iter) << endl;
    }
    else
    {
        cout << "no elements are greater than "<<random_int << endl;
    }
    pair<list<int>::iterator,list<int>::iterator> range=equal_range(int_list.begin(),int_list.end(),random_int);
    cout << "The largest subrange is between "<<*range.first<<" and "<<*range.second<< endl;
    cout << "multiset container" << endl;
    show(int_multiset);
    random_int=rand()%20;
    auto it=int_multiset.lower_bound(random_int);
    if (it!=int_multiset.end())
    {
        cout << "The first element that is not less than "<<random_int<<" is "<<*it << endl;
    }
    else
    {
        cout << "Every element is less than "<<random_int << endl;
    }
    it=int_multiset.upper_bound(random_int);
    if (it!=int_multiset.end())
    {
        cout << "The first element that is greater than "<<random_int<<" is "<<*it << endl;
    }
    else
    {
        cout << "no elements are greater than "<<random_int << endl;
    }
    pair<multiset<int>::iterator,multiset<int>::iterator> it_range=int_multiset.equal_range(random_int);
    cout << "The largest subrange is between "<<*it_range.first<<" and "<<*it_range.second<< endl;
    return 0;
}
